unit uBaseForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, XPMenu, XPMan, Menus, StdCtrls, Grids, DBGrids;

type
  TfBaseForm = class(TForm)
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    FXPMenu: TXPMenu;
  protected
    procedure DBGridDrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
  public
    { Public declarations }
  end;

var
  fBaseForm: TfBaseForm;
  FRowColors: array[0..1] of TColor = (clWindow, clSkyBlue);

implementation

{$R *.dfm}

procedure TfBaseForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  FXPMenu.Active := False;
  Application.ProcessMessages;
end;

procedure TfBaseForm.FormCreate(Sender: TObject);
begin
  FXPMenu := TXPMenu.Create(Self);
  FXPMenu.XPControls := [xcMainMenu, xcPopupMenu, xcSpeedButton];
  FXPMenu.Gradient   := True;
end;

procedure TfBaseForm.FormDestroy(Sender: TObject);
begin
  FXPMenu.Free;
end;

procedure TfBaseForm.FormShow(Sender: TObject);
begin
  FXPMenu.Active := True;
end;

procedure TfBaseForm.DBGridDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
var
  GridTmp: TDBGrid;
  CanvasTmp: TCanvas;
begin
  if gdSelected in State then
    Exit;
  GridTmp := (Sender as TDBGrid);
  CanvasTmp := GridTmp.Canvas;

  if ((GridTmp.DataSource.DataSet.RecNo mod 2) = 1) then
    CanvasTmp.Brush.Color := FRowColors[1]
  else
    CanvasTmp.Brush.Color := FRowColors[0];

  CanvasTmp.Font.Color := clBlack;
  GridTmp.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

end.
